/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package examplesocket;

import java.util.Enumeration;
import java.util.concurrent.ConcurrentHashMap;

/**
 *
 * @author caos
 */
public class Pinger extends Thread
{
    private ConcurrentHashMap<String, Stream> toPing;
    Boolean stillRunning;
    Pinger(ConcurrentHashMap<String, Stream> toPing)
    {
        this.toPing = toPing;
        stillRunning = true;
    }
    
    void pingerStopper()
    {
        stillRunning = false;
    }
    
    @Override
    public void run()
    {
        while(stillRunning)
        {
            Enumeration<Stream> streamToPing = toPing.elements();
            while(streamToPing.hasMoreElements())
            {
                Stream tempStream = streamToPing.nextElement();
                if(!tempStream.isConnected())
                {
                    tempStream.stopStream();
                }
            }
        }
    }
}
